package com.etc.dynamicproxy2.dynamicproxy;

import com.etc.dynamicproxy.MyAop;

import java.lang.reflect.Proxy;

/**
 * @author: knowno
 * @create: 2025-09-22 15:19
 * @Version 1.0
 **/
public class TestAop {
    public static void main(String[] args) {

        //要代理的目标对象1
        OrderService orderService = new OrderServiceImpl();

        //创建代理对象
        MyAop2 myAop = new MyAop2(orderService);

        //调用Proxy对象 newProxyInstance
        OrderService myservice = (OrderService) Proxy.newProxyInstance(OrderServiceImpl.class.getClassLoader(),
                new Class<?>[] { OrderService.class },
                myAop);

        //调用方法
        myservice.pay();


    }
}
